package com.jingdun.sport.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jingdun.sport.bean.model.Questions;
import com.jingdun.sport.dao.QuestionsMapper;
import com.jingdun.sport.service.QuestionsService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
@Slf4j
@AllArgsConstructor
public class QuestionsServiceImpl extends ServiceImpl<QuestionsMapper, Questions> implements QuestionsService {

    private QuestionsMapper questionMapper;

    public void addQuestion(Questions question){
        questionMapper.addQuestion(question);
    }

    public Questions getQuestionDetail(@Param("params") Map<String, Object> m){
        return questionMapper.getQuestionDetail(m);
    }

    public void updateQuestion(Questions question){
        questionMapper.updateQuestion(question);
    }
    
    public Page<Map<String, Object>> getPaginationQuestions(@Param("params") Map<String, Object> m){
        //新建分页
        Page<Map<String,Object>> page =new Page<Map<String,Object>>((long)m.get("current"), (long)m.get("size"));
        //返回结果
        page.setRecords(this.baseMapper.getPaginationQuestions(page, m));
        return page;
    }
}
